package co.uniquindio.software.medisys.logica;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import co.uniquindio.software.medisys.entidades.Cuentaparticular;

public class GestorCuentaParticular {
	EntityManagerFactory emf = Persistence
			.createEntityManagerFactory("MedisysPU");

	
	public Cuentaparticular consultarCuenta(int id){
		EntityManager em = emf.createEntityManager();
		return em.find(Cuentaparticular.class, id);
	}
	
	public void guardarCuentaParticular(Cuentaparticular cuenta) {

		EntityManager em = emf.createEntityManager();
		EntityTransaction et = em.getTransaction();
		et.begin();
		em.persist(cuenta);
		em.flush();
		et.commit();
	}

	public void modificarCuentaParticular(Cuentaparticular cuenta) {

		EntityManager em = emf.createEntityManager();
		EntityTransaction et = em.getTransaction();
		et.begin();
		em.merge(cuenta);
		em.flush();
		et.commit();
	}


}
